package com.tech.tool.service.impl;

import com.tech.tool.dataobject.AppHost;
import com.tech.tool.exception.ToolException;
import com.tech.tool.repository.AppHostRepository;
import com.tech.tool.service.AppHostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.NoSuchElementException;

@Service
public class AppHostServiceImpl implements AppHostService {

    @Autowired
    AppHostRepository repository;

    @Override
    public AppHost save(AppHost appHost) {
        return repository.save(appHost);
    }

    @Override
    public AppHost findOne(Integer hostId) {
        try {
            return repository.findById(hostId).get();
        } catch (NoSuchElementException e) {
            throw new ToolException(3, "11234");
        }
    }
}
